﻿/* A dictionary is stored as a sequence of text lines containing words and their explanations. 
 * Write a program that enters a word and translates it by using the dictionary. 
 * Sample dictionary:
.NET - platform for applications from Microsoft
CLR - managed execution environment for .NET
namespace - hierarchical organization of classes
*/
using System;
using System.Text.RegularExpressions;

namespace _14.Translator
{
    class Translator
    {
        static void Main()
        {
            string dictionary = @"
                                .NET - platform for applications from Microsoft
                                CLR - managed execution environment for .NET
                                namespace - hierarchical organization of classes";
            Console.WriteLine("Enter a word: ");
            string word = Console.ReadLine();

            string[] words = dictionary.Split('\n');
            
            Regex r = new Regex(@word + @"\s\-\s(.*)\n", RegexOptions.IgnoreCase);
            if (!r.IsMatch(dictionary)) Console.WriteLine("No matches");
            else
            {
                Console.WriteLine("Found occurances of {0}", word);
                foreach (Match m in r.Matches(dictionary))
                {
                    Console.WriteLine(m.Groups[0].Value.ToString());
                }
            }
        }
    }
}
